-- CALC_CAVE_16_TARGET_CLASS

-- 计算走私者残骸的中心格子类型
return function()
    local caisson  = { ["class"] = 74, ["ratio"] = 60 }; -- 弹药箱
    local gunner   = { ["class"] = 82, ["ratio"] = 15 }; -- 机枪兵的残骸
    local corsair  = { ["class"] = 77, ["ratio"] = 15 }; -- 海贼的残骸（杰克船长）
    local smuggler = { ["class"] = 76, ["ratio"] = 30 }; -- 走私者残骸

    local arr = { caisson, gunner, corsair, smuggler};

    -- 残骸只出现一次
    if DungeonInstanceM.getInstanceStat(gunner["class"]) > 0 then
        gunner["ratio"] = 0;
    end
    if DungeonInstanceM.getInstanceStat(corsair["class"]) > 0 then
        corsair["ratio"] = 0;
    end

    -- 迷宫小关不出现
    local dungeonId = DungeonM.getDungeonId();
    if type(dungeonId) == "number" and dungeonId > 0 and
       DungeonAreaM.query(dungeonId, "type") == "child" then
        gunner["ratio"] = 0;
        corsair["ratio"] = 0;
    end

    -- 先过滤一遍
    DungeonInstanceM.filterInstanceGrids(arr);

    local seed = DungeonM.getRandSeed("CALC_CAVE_16_TARGET_CLASS");
    local info = fetchElemBySeed(arr, seed);

    return info["class"];
end
